import java.lang.reflect.Array;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int k=3;
        int[] nums={1,2,3,4,5,6,7};

        k=k%nums.length;
        int j=0;
        for(int i=nums.length-k;i<nums.length;i++){
            int tmp=nums[i];
            nums[i]=nums[j];
            nums[j]=tmp;
            j++;
            System.out.println(Arrays.toString(nums));
        }
    }
    public static void main1(String[] args) {
        int[] nums={9,6,4,2,3,5,7,0,1};
        Arrays.sort(nums);
        for(int i=0;i<nums.length;i++){
            if(nums[i]!=i){
                System.out.println(i);
                return;
            }
        }
    }
}
